package com.fisherman.condition;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

import java.util.concurrent.TimeUnit;

/**
 * @User: fisherman
 * @Date: 2020/5/19 10:14
 */

//判断下是否是Windows系统
public class FishermanCondition implements Condition {
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        //获取当前资源信息
        Environment environment = context.getEnvironment();
        //获取操作系统的名字
        String property = environment.getProperty("os.name");

        if (property.contains("Windows")){
            return true;
        }
        return false;
    }
}
